/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.wdm.hibernateUtils;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 *
 * @author thanasis
 */
public class HibernateConnection {
    private static SessionFactory sessionFactory;
    
    public static SessionFactory openSession(){
        sessionFactory = new AnnotationConfiguration()
                .configure() // configures settings from hibernate.cfg.xml
                .buildSessionFactory();
        return sessionFactory;
    }
    
    public static void closeSession(){
        if ( sessionFactory != null ) {
			sessionFactory.close();
		}
    }
}
